Filtering objects without outgoing and incoming links

I am trying to filter the module objects for no outgoing and incoming links, but some how it is fetching the incoming links inside the module.

Please help out.

Code:

string strObjType = ""

for obj in mod do {

strObjType = obj. "Object Type"

bool bOutgoingLink,bIncomingLink

Object obj

Link lOut, lIncoming

bOutgoingLink = false

bIncomingLink = false

for lOut in obj -> "*" do

{

bOutgoingLink = true

}

for lIncoming in "*" <- obj do

{

bIncomingLink = true

}

 

//Fetching the filtered objects using other filter conditions too

if(ObjType == "R") && (ObjType == "Design")

{

if(bOutgoingLink == false) && (bIncomingLink == false)

{

// proceess the data

}

}

}

When I am processing the data it is also fetching the incoming links objects.

Please help me.

 


KBSri - Wed Mar 04 05:18:00 EST 2015

Re: Filtering objects without outgoing and incoming links
O.Wilkop - Wed Mar 04 06:48:54 EST 2015

your "for lIncoming in "*"<-obj do" loop only loops through links/objects of modules that are currently opened. Since you probably don't have all of your source modules open at that time, you might want to use the "for LinkRef in object <- "*" do" loop instead.

 

Object obj = current;
LinkRef lr = null;
for lr in obj <- "*" do{
    print "link found\n";
}

 

Re: Filtering objects without outgoing and incoming links
Wolfgang Uhr - Wed Mar 04 07:42:14 EST 2015

Hi

If you have:

  1. an incoming link
  2. a source module for this link, which is not loaded

Then the following snippet does not work korrekt.

for lIncoming in "*" <- obj do { 
    bIncomingLink = true 
}

You have either

  1. To load the source module first
  2. To use LinkRef instead of Link

Best regards

Wolfgang

Re: Filtering objects without outgoing and incoming links
KBSri - Wed Mar 04 12:40:18 EST 2015

Wolfgang Uhr - Wed Mar 04 07:42:14 EST 2015

Hi

If you have:

  1. an incoming link
  2. a source module for this link, which is not loaded

Then the following snippet does not work korrekt.

for lIncoming in "*" <- obj do { 
    bIncomingLink = true 
}

You have either

  1. To load the source module first
  2. To use LinkRef instead of Link

Best regards

Wolfgang

Dear Wolfgang and Wilkop,

Thanks for the suggestion. Actually I do not need to load the source module in this link. 

Some how It was fetching incoming links though I have been passing the boolean value inside the function. 

I will try using LinkRef instead of Link. Hope it does not fetch the incoming links.

Re: Filtering objects without outgoing and incoming links
GregM_dxler - Fri Mar 06 09:32:57 EST 2015

KBSri - Wed Mar 04 12:40:18 EST 2015

Dear Wolfgang and Wilkop,

Thanks for the suggestion. Actually I do not need to load the source module in this link. 

Some how It was fetching incoming links though I have been passing the boolean value inside the function. 

I will try using LinkRef instead of Link. Hope it does not fetch the incoming links.

Hello KBSri,

You may want to look at your logic.

You may do your processing if you have incoming links but no outgoing links.  This is because you are using bOutgoingLink == false && bIncomingLink == false.  If bOutgoingLink is false (no outgoing links), then the equation will be false, regardless of what bIncomingLink is set to.

A = B && C :  A will be false if either B or C is false.  It will only be true if both B and C are true.

I think you want the opposite, do the loop if there are no outgoing or incoming links at all.

if (!( bOutgoingLInk || bIncomingLink))

Alternately, you could use deMorgan's theorem and use if(!bOutgoingLink && !bIncomingLink)

Hope this helps,

Greg